package com.weng.bigdata.micro.service.schedule.center.feign;

import com.weng.bigdata.micro.service.common.ServicesConstants;
import com.weng.bigdata.micro.service.schedule.center.fallback.ScheduleJobFallBack;
import com.weng.bigdata.micro.service.schedule.center.model.AddJobReq;
import com.weng.bigdata.micro.service.schedule.center.model.UpdateJobReq;
import com.weng.bigdata.micro.service.warehouse.adapter.fallback.WarehouseExecuteFallBack;
import com.weng.bigdata.micro.service.warehouse.adapter.model.req.ExecuteSqlReq;
import com.weng.framework.core.model.ResponseData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 调度
 *
 * @author wengzhonghui
 * @date 2021/4/2 11:07
 */
@FeignClient(name = ServicesConstants.SCHEDULE_CENTER_API_SERVER_NAME, fallback = ScheduleJobFallBack.class, configuration = ScheduleJobFallBack.class)
public interface ScheduleJobFeignService {

    String URL_PREFIX = "/jobs";

    /**
     * 新增调度任务配置信息
     */
    @PostMapping(value = URL_PREFIX )
    ResponseData add(@Valid @RequestBody AddJobReq addJobReq);

    /**
     * 更新调度任务配置信息
     */
    @PutMapping(value = URL_PREFIX )
    ResponseData update(@RequestBody UpdateJobReq updateJobReq);


    /**
     * 删除调度任务配置信息
     */
    @DeleteMapping(value = URL_PREFIX + "/{jobId}/delete")
    ResponseData delete(@PathVariable("jobId") String id);

    /**
     * 批量删除调度任务配置信息
     */
    @DeleteMapping(value = URL_PREFIX + "/delete-batch")
    ResponseData deleteBatch(String ids);

    /**
     * 打开任务调度
     */
    @PostMapping(value = URL_PREFIX + "/{scheduleJobId}/trigger/on")
    ResponseData start(@PathVariable("scheduleJobId") String id);

    /**
     * 关闭任务调度
     */
    @PostMapping(value = URL_PREFIX + "/{scheduleJobId}/trigger/off")
    ResponseData stop(@PathVariable("scheduleJobId") String id);
}
